Introduction to Software Engineering, Second Edition by Ronald J. Leach

Introduction to Software Engineering, Second Edition by Ronald J. Leach

Author:Ronald J. Leach
Language: eng
Format: epub


would declare the type to be an unsigned int, since strings cannot have negative length. We must have a constructor function to initialize the contents of the string and we must have a function to display the contents on the appropriate output stream.

Note what we have not determined yet. There has been no mention of the null byte \0

to be used as a termination byte to indicate the end of the string; hence, another question arises as to whether that termination byte is to be counted as part of the string, thereby increasing its length by one.

Indeed, there is no requirement that the string should be implemented as a set of contiguous bytes. We could choose to follow the lead of many word processing programs

Software Design ◾ 183

(including the one in which this book is written) and use linked lists to chain together contiguous arrays of characters (and other objects, such as graphs and images, in the case of the word processor). Linked lists are especially suited to insertions and deletions of text and other objects within a word processing document. Other data organizations are possible.

The important point is that none of the decisions about the implementation organiza-

tion or details is relevant to the string object. What we need now is a determination of the attributes of the object and a set of possible values for each attribute. With such a determination, we can write the first attempt of a description of the class. Thus, the first attempt at the definition of a string object will probably have a definition something like the class string defined next. We will not worry about syntax at this point.

class String

Member functions:

int length;

int strlen( String s);

void display( String s);

Some problems arise here because we have not precisely determined the interface. The

constructor member function needs to have a size specified for the length of the string.

Other member functions will have to have their interfaces determined, also. Thus, we

might have to make a second iteration of the design of the class representing strings.

class String

Member functions:

int length;

String (char *arr); //terminated by \0

int strlen();

operator << ;

There are more iterations that need to be performed in order to have a complete definition of the interfaces of the String class. Of course, we still have to develop an implementation of the methods. We omit the details of the iteration for the class description at this point since this class is part of the standard library for the C++ language and nearly every other object-oriented programming language in common use.

4.8 OBJECT-ORIENTED DESIGN REPRESENTATIONS

In this section, we will present a simple object model for the medical device terminal concentrator software system described in Section 4.4. We will make no attempt to refine the object model and will keep it at the same high level that we used for the previous models using different design representations.

The representation is simple (at least at this point). We will use a rectangular box

to describe an object, with diamond-shaped boxes and line segments used to indicate

184 ◾ Introduction to Software Engineering

relationships between objects.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.